package com.ssy.lingxi.contract.repository;

import com.ssy.lingxi.contract.entity.PurchaseInquiryDO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;

/**
 * 采购询价合同
 * @author 伍将
 * @date 2021/3/4
 * @version 2.0.0
 */
public interface PurchaseInquiryRepository extends JpaRepository<PurchaseInquiryDO, Long>, JpaSpecificationExecutor<PurchaseInquiryDO> {

    /**
     * 查询采购询价合同是否存在
     * @author 伍将
     * @date 2021/3/4
     * @param demandMemberId:需求发布会员id
     * @param demandRoleId: 需求发布会员角色id
     * @param awardMemberId: 授标会员id
     * @param awardRoleId: 授标会员角色id
     * @param demandId: 需求单id
     * @return 是否存在:false-否，true-是
     **/
    Boolean existsByDemandMemberIdAndDemandRoleIdAndAwardMemberIdAndAwardRoleIdAndDemandId(Long demandMemberId, Long demandRoleId, Long awardMemberId, Long awardRoleId, Long demandId);

    /**
     * 查询采购询价合同
     * @author 伍将
     * @date 2021/3/4
     * @param demandMemberId:需求发布会员id
     * @param demandRoleId: 需求发布会员角色id
     * @param awardMemberId: 授标会员id
     * @param awardRoleId: 授标会员角色id
     * @param demandId: 需求单id
     * @return 采购询价合同
     **/
    PurchaseInquiryDO findByDemandMemberIdAndDemandRoleIdAndAwardMemberIdAndAwardRoleIdAndDemandId(Long demandMemberId, Long demandRoleId, Long awardMemberId, Long awardRoleId, Long demandId);

    /**
     * 查询采购询价合同是否存在
     * @author 伍将
     * @date 2021/3/4
     * @param demandMemberId:需求发布会员id
     * @param demandRoleId: 需求发布会员角色id
     * @param awardMemberId: 授标会员id
     * @param awardRoleId: 授标会员角色id
     * @param demandId: 需求单id
     * @param isCreate: 是否创建合同:0-否，1-是
     * @return 是否存在:false-否，true-是
     **/
    Boolean existsByDemandMemberIdAndDemandRoleIdAndAwardMemberIdAndAwardRoleIdAndDemandIdAndIsCreate(Long demandMemberId, Long demandRoleId, Long awardMemberId, Long awardRoleId, Long demandId, Integer isCreate);
}

